import request from "@/utils/request.js"

const uploadUrl = import.meta.env.VITE_APP_UPLOAD_URL
// 获取上传文件token
export function getUploadToken () {
  return request({
    baseURL: uploadUrl,
    url: `/prepare/uploadtoken`,
    method: 'post',
    headers: {
      appId: 'standard',
      appSecret: '123456'
    },
    noToken: true,
    params: {
      fileBucket: 'standard',
      userId: 123
    }
  })
}
export function uploadFile (data) {
  return request({
    baseURL: uploadUrl,
    url: `/FileUpload`,
    method: 'post',
    headers: {
      "content-type": "multipart/form-data"
    },
    params: {
      correlationId: '111',
      fileBucket: 'standard'
    },
    data
  })
}

// 获取下载文件token
export function getDownloadtoken (id) {
  return request({
    baseURL: uploadUrl,
    url: `/prepare/downloadtoken`,
    method: 'post',
    headers: {
      appId: 'standard',
      appSecret: '123456'
    },
    noToken: true,
    params: {
      fileId: id,
      userId: 123
    },
    data: {}
  })
}
export function downloadFile (params) {
  return request({
    baseURL: uploadUrl,
    url: `/downloadFile`,
    method: 'get',
    params
  })
}
